# coding=utf-8

from flask import request, render_template, url_for
from over.handlers.my import mod
from over.handlers.router import Router
from over.handlers.role import role_required_admin
from over.model import db, Server

router = Router()


@router('/server')
class ServerRouter(object):
    __router_name__ = 'server'

    @router('/')
    @role_required_admin
    def index(self):
        servers = Server.query.all()

        return render_template('my/server/index.html', servers=servers)

    @router('/', methods=['GET', 'POST'])
    @role_required_admin
    def add_account(self):
        server_id = request.args.get('server')
        server = Server.query.get_or_404(server_id)



        return render_template('my/server/account.html', server=server)


router.register_url_rules(mod)
